package com.neusoft.cmsprojects.intercepter;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.neusoft.cmsprojects.model.TbUser;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class LoginItercepter extends AbstractInterceptor {

	private static final long serialVersionUID = 1L;

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		  if(invocation.getAction().getClass().getName().contains("LoginAction")) 
	        {  
	            return invocation.invoke();  
	        } 
		Map map= invocation.getInvocationContext().getSession();
	     if(null==map.get("user")) 
	        {  
	           return Action.LOGIN; 
	        } else{
	        	 return invocation.invoke();  
	        } 
	          
	       
	    }  
	}


